#include <iostream>
#include <string>
#include <memory>

using namespace std;

/*
\ brief:  图片抽象接口类
\ author: 清晨与猫鱼
*/
class Image {
public:
    virtual void display() = 0;     // 接口显示函数
};


/*
\ brief:  实时图像
\ author: 清晨与猫鱼
*/
class RealImage 
    : public Image {
public:
    explicit RealImage(string fileName)
        : fileName_(move(fileName)) {  
        loadFromDisk();        
    }

    void display() {
        cout << "Displaying " + fileName_ << endl;
    }

    void loadFromDisk() {
        cout << "Loading " + fileName_ << endl;
    }

private:
    string fileName_;
};


/*
\ brief:  图片代理
\ author: 清晨与猫鱼
*/
class ProxyImage 
    : public Image {
public:
    explicit ProxyImage(string fileName)
        : fileName_(move(fileName)) {            
    }

    void display() {
        if (!realImage_) {
            realImage_.reset(new RealImage(fileName_));
        }
        realImage_->display();
    }

private:
    string fileName_;
    unique_ptr<RealImage> realImage_;
};